import unittest
from selenium import webdriver
from selenium.webdriver import Keys
from selenium.webdriver.chrome.service import Service


class UnittestChromeDriver(unittest.TestCase):
    driver = None

    @classmethod
    def setUpClass(cls) -> None:
        cls.service = Service(executable_path='../driver_exe/chromedriver.exe')
        cls.driver = webdriver.Chrome(service=cls.service)

    def test_baidu(self):
        """
        测试 百度的搜索 功能
        :return:
        """
        self.driver.get('https://www.baidu.com')
        self.driver.find_element_by_id('kw').send_keys('selenium', Keys.RETURN)
        # self.driver.find_element_by_id('su').click()

    @classmethod
    def tearDownClass(cls) -> None:
        cls.driver.close()
        # cls.driver.quit()


if __name__ == '__main__':
    pass
